package com.xc.quartz.plugIn;

import java.util.Date;
import java.util.Iterator;
import java.util.Set;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SimpleJob implements Job {
	private static Logger _log = LoggerFactory.getLogger(SimpleJob.class);

	public void execute(JobExecutionContext context)
			throws JobExecutionException {

		// This job simply prints out its job name and the
		// date and time that it is running
		String jobName = context.getJobDetail().getFullName();
		_log.info("Executing job: " + jobName + " executing at " + new Date()
				+ ", fired by: " + context.getTrigger().getName());

		if (context.getMergedJobDataMap().size() > 0) {
			Set keys = context.getMergedJobDataMap().keySet();
			Iterator itr = (Iterator) keys.iterator();
			while (itr.hasNext()) {
				String key = (String) itr.next();
				String val = context.getMergedJobDataMap().getString(key);
				_log.info(" - jobDataMap entry: " + key + " = " + val);
			}
		}

		context.setResult("hello");

	}
}
